﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Customer_Profile.eCard.DBDao;
namespace Customer_Profile.eCard
{
    public partial class DealSettle : System.Web.UI.Page
    {
        string dealno = "";
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Request["dealno"] != null)
            {
                dealno = Request["dealno"].ToString();
            }

            if (!Page.IsPostBack)
            {
                DataSet dsAgent = SettleAgentDao.getSettleAgentList("N");
                dropSettleAgent.DataSource = dsAgent;
                dropSettleAgent.DataTextField = "settle_agent_name";
                dropSettleAgent.DataValueField = "settle_agent_name";
                dropSettleAgent.DataBind();
            }
        }

        protected void btnSettle_Click(object sender, EventArgs e)
        {
            string settleAgentName = dropSettleAgent.SelectedItem.Value;
            string settleInpuDate = txtInputDate.Text.Trim();
            string payDate = txtPayDate.Text.Trim();
            bool bok = DealDao.settle(dealno, settleAgentName, settleInpuDate, payDate);
            if (bok)
            {
                Response.Write("<script language=javascript>alert('success');</script>");
            }
            else
            {
                Response.Write("<script language=javascript>alert('error');</script>");
            }
        }
    }
}